function customizeGlImpact(transactionRecord, standardLines, customLines, book) {
    try {
        var operationNumber = transactionRecord.getFieldText('startoperation');
        var operationCharCode = String.fromCharCode(64 + parseInt(operationNumber));
        //将工序号identify1,2,3,4转化成A,B,C,D
        var identify = transactionRecord.getFieldValue('custbody_identify');
        var identifyCharCode = String.fromCharCode(64 + parseInt(identify));

        var comCode = 'Y' + operationCharCode + identifyCharCode;
        var customerGLImpactAmount = '';


        var isbackflush = transactionRecord.getFieldValue('isbackflush');
        var operationId = transactionRecord.getFieldValue('startoperation');
        var manufacturingoperationtaskRec = nlapiLoadRecord('manufacturingoperationtask', operationId);
        var manufacturingcosttemplateId = manufacturingoperationtaskRec.getFieldValue('manufacturingcosttemplate');
        var manufacturingcosttemplateRec = nlapiLoadRecord('manufacturingcosttemplate', manufacturingcosttemplateId);

        //生产成本 AccountId：1345
        var manufacturingCostAccountId = 1345;
        //应付职工薪酬 : 职工薪酬 AccountId:807
        var employeeSalaryAccountId = 807;
        // 制造费用 : 制造费用（add） AccountId :1900
        var manufacturingFeeAccountId = 1900;
        //生产成本:直接人工 AccountId:863
        var manufacturingCostDirectLaborAccountId = 863;
        //生产成本:制造费用 AccountId:875
        var manufacturingCostManufacturingFeeAccountId = 875;
        //委托加工物资-材料加工费 AccountId:1454
        var materialProcessingFeeAccountId = 1454;
        //委托加工物资 : 材料加工 AccountId:1452
        var materialProcessingAccountId = 1452;



        if (isbackflush === 'F') {//工单完成
            for (var i = 0; i < standardLines.getCount(); i++) {
                var currLine = standardLines.getLine(i);
                var accountId = currLine.getAccountId();
                //冲销插入
                // 借：应付职工薪酬：职工薪酬 贷：生产成本；
                // 借：制造费用：制造费用（add） 贷：生产成本
                if (accountId === 807) {
                    var amount = currLine.getCreditAmount();
                    if (amount > 0) {
                        addDebitCustomLines(customLines, amount, 807, "冲销借方 应付职工薪酬:职工薪酬");
                    }
                }
                if (accountId === 1900) {
                    var amount = currLine.getCreditAmount();
                    if (amount > 0) {
                        addDebitCustomLines(customLines, amount, 1900, "冲销借方  制造费用:制造费用(add)");
                    }
                }
                if (accountId === 1345) {
                    var amount = currLine.getDebitAmount();
                    if (amount > 0) {
                        addCreditCustomLines(customLines, amount, 1345, "冲销贷方 生产成本");
                    }
                }
            }
            //插入GL
            var reportworkQuantity = transactionRecord.getFieldValue('custbody_reportwork_qty');
            if (reportworkQuantity) {
                reportworkQuantity = parseInt(reportworkQuantity);
            } else {
                reportworkQuantity = 0;
            }

            //工序对应计件工价
            var operationPrice = manufacturingcosttemplateRec.getFieldValue('custrecord_price');
            //工序对应成本模板的单件制造费用
            var operationManufactureFee = manufacturingcosttemplateRec.getFieldValue('custrecord_manufacturefee');
            var operationTotalPrice = parseFloat(operationPrice) * parseFloat(reportworkQuantity);
            var operationTotalManufactureFee = parseFloat(operationManufactureFee) * parseFloat(reportworkQuantity);
            //借： 生产成本 : 直接人工 贷： 应付职工薪酬 : 职工薪酬，
            //借： 生产成本  贷： 生产成本 : 直接人工”并且金额为：“报工数量”x“工序对应计件工价”；
            addDebitCustomLines(customLines, operationTotalPrice, 863, "产生借方 生产成本-直接人工");
            addCreditCustomLines(customLines, operationTotalPrice, 807, "产生贷方 应付职工薪酬:职工薪酬");
            addDebitCustomLines(customLines, operationTotalPrice, 1345, "产生借方 生产成本");
            addCreditCustomLines(customLines, operationTotalPrice, 863, "产生贷方 生产成本:直接人工");

            customerGLImpactAmount += operationTotalPrice + ';';

            //借： 生产成本 : 制造费用 贷： 制造费用：制造费用（add），
            //借： 生产成本  贷： 生产成本 : 制造费用 并且金额为：“报工数量”x“工序对应成本模板的单件制造费用”；
            addDebitCustomLines(customLines, operationTotalManufactureFee, 875, "产生借方 生产成本:制造费用");
            addCreditCustomLines(customLines, operationTotalManufactureFee, 1900, "产生贷方 制造费用制造费用(add)");
            addDebitCustomLines(customLines, operationTotalManufactureFee, 1345, "产生借方 生产成本");
            addCreditCustomLines(customLines, operationTotalManufactureFee, 875, "产生贷方 生产成本:制造费用");

            customerGLImpactAmount += operationTotalManufactureFee + ';';
        }
        //工单完成  带反冲
        else if (isbackflush === 'T') {
            for (var i = 0; i < standardLines.getCount(); i++) {
                var currLine = standardLines.getLine(i);
                var accountId = currLine.getAccountId();
                // 冲销
                // 借：应付职工薪酬 : 职工薪酬  贷：生产成本；
                // 借：制造费用：制造费用（add） 贷：生产成本；
                if (accountId === 807) {
                    var amount = currLine.getCreditAmount();
                    if (amount > 0) {
                        addDebitCustomLines(customLines, amount, 807, "冲销借方 应付职工薪酬:职工薪酬");
                        addCreditCustomLines(customLines, amount, 1345, "冲销贷方 生产成本");
                    }
                } else if (accountId === 1900) {
                    var amount = currLine.getCreditAmount();
                    if (amount > 0) {
                        addDebitCustomLines(customLines, amount, 1900, "冲销借方 制造费用:制造费用(add)");
                        addCreditCustomLines(customLines, amount, 1345, "冲销贷方 生产成本");
                    }
                }
                // 冲销
                //借：委托加工物资-材料深加工费/材料加工费/工序加工费  贷：生产成本
                //借：生产成本 贷：委托加工物资-材料深加工费/材料加工费/工序加工费   金额为对应采购订单的金额
                else if (accountId === 1453 || accountId === 1454 || accountId === 1457) {
                    var amount = currLine.getCreditAmount();
                    if (amount > 0) {

                        addDebitCustomLines(customLines, amount, accountId, "冲销借方");
                        addCreditCustomLines(customLines, amount, 1345, "冲销贷方 生产成本");

                        var createdfromId = transactionRecord.getFieldValue('createdfrom');
                        //Define search filter expression
                        var filterExpression = [['createdfrom', 'is', createdfromId]];
                        if (accountId === 1453){
                            filterExpression[filterExpression.length] = 'and';
                            filterExpression[filterExpression.length] = ['anylineitem', 'is', '866'];
                        }
                        if (accountId === 1454){
                            filterExpression[filterExpression.length] = 'and';
                            filterExpression[filterExpression.length] = ['anylineitem', 'is', '49'];
                        }
                        if (accountId === 1457){
                            filterExpression[filterExpression.length] = 'and';
                            filterExpression[filterExpression.length] = ['anylineitem', 'is', '868'];
                        }
                        var columns = [];
                        columns[0] = new nlobjSearchColumn('internalid');
                        //Create the saved search
                        var search = nlapiCreateSearch('purchaseorder', filterExpression, columns);
                        var resultSet = search.runSearch();

                        resultSet.forEachResult(function (searchResult) {
                            var poId = searchResult.getValue('internalid');
                            var poRec = nlapiLoadRecord('purchaseorder', poId);
                            var rate = poRec.getLineItemValue('item', 'rate', 1);
                            nlapiLogExecution('DEBUG', 'rate', rate);

                            var operationNumber = transactionRecord.getFieldText('startoperation');
                            nlapiLogExecution('DEBUG', 'operationNumber', operationNumber);

                            var componentLine = transactionRecord.getLineItemCount('component');
                            var itemLineQuantity;
                            for (var i = 0; i < componentLine; i++) {
                                var operationsequencenumber = transactionRecord.getLineItemValue('component', 'operationsequencenumber', (i + 1));
                                // nlapiLogExecution('DEBUG', 'operationsequencenumber', operationsequencenumber);
                                if (operationNumber == operationsequencenumber) {
                                    var lineItemId = transactionRecord.getLineItemValue('component', 'item', (i + 1));
                                    if (lineItemId == '868' || lineItemId == '49' || lineItemId == '866') {
                                        itemLineQuantity = transactionRecord.getLineItemValue('component', 'quantity', (i + 1))
                                    }
                                }
                            }
                            nlapiLogExecution('DEBUG', 'itemLineQuantity', itemLineQuantity);
                            var amount = parseFloat(rate) * parseFloat(itemLineQuantity);

                            addDebitCustomLines(customLines, amount, 1345, "产生借方 生产成本");
                            addCreditCustomLines(customLines, amount, accountId, "产生贷方");

                            customerGLImpactAmount += amount + ';';

                            return false;//不迭代
                        });
                    }
                } else if (accountId !== 1345) {
                    var amount = currLine.getCreditAmount();
                    if (amount > 0) {
                        //冲销:借：原材料【即对应货品上的资产科目】 贷：生产成本（冲销：金额是目前系统金额）
                        addDebitCustomLines(customLines, amount, accountId, "冲销借方 原材料");
                        addCreditCustomLines(customLines, amount, 1345, "冲销贷方 生产成本");


                        var processTypeId = manufacturingcosttemplateRec.getFieldValue('custrecord_processtype');
                        var accountId0;
                        if (processTypeId === '1') {
                            accountId0 = 1452;
                        } else if (processTypeId === '2') {
                            accountId0 = 781;
                        } else if (processTypeId === '3') {
                            accountId0 = 1459;
                        }
                        // 插入:
                        //借：委托加工物资 : 材料加工【即对应原材料上的委外科目】  贷：原材料【即对应货品上的资产科目】
                        //借：生产成本 贷：委托加工物资 : 材料加工【即对应原材料上的委外科目】
                        addDebitCustomLines(customLines, amount, accountId0, "产生借方");
                        addCreditCustomLines(customLines, amount, accountId, "产生贷方 原材料");
                        addDebitCustomLines(customLines, amount, 1345, "产生借方 生产成本");
                        addCreditCustomLines(customLines, amount, accountId0, "产生贷方");

                        customerGLImpactAmount += amount + ';';
                    }
                }
            }
        }
        var woId = transactionRecord.getFieldValue('createdfrom');
        var woRec = nlapiLoadRecord('workorder', woId);
        var oldGLImpact = woRec.getFieldValue('custbody_gl_impact_record');
        if (oldGLImpact == null) {
            oldGLImpact = '';
        }
        //如果有Id,则是编辑状态,编辑后要  对原先的总账进行更新
        if (transactionRecord.getId()) {
            var strArray = oldGLImpact.split('|');
            for (var index in strArray) {
                if (strArray[index].indexOf(comCode) !== -1) {
                    strArray[index] = comCode + customerGLImpactAmount;
                }
            }
            var newGLImpact = strArray.join('|');
            woRec.setFieldValue('custbody_gl_impact_record', newGLImpact);
        }
        //如果没有,则是创建状态  ,  创建直接添加
        else {
            var customerGLImpact = comCode + customerGLImpactAmount + '|';
            woRec.setFieldValue('custbody_gl_impact_record', oldGLImpact + customerGLImpact);
        }
        nlapiSubmitRecord(woRec, true);
    } catch (e) {
        nlapiLogExecution('DEBUG', 'e', JSON.stringify(e));
    }
}